home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / OOmodules / list / doublylinked / stringlist / test.e < prev    next >
Encoding:
Text File  |  1996-09-10  |  1.0 KB  |  62 lines

  1. /*
  2.  
  3. Small test program for the stringList object.
  4.  
  5. Allocate a stringList, insert some strings alpha-sorted and print it.
  6.  
  7. */
  8.  
  9. MODULE 'oomodules/list/doublylinked/stringlist'
  10.  
  11. PROC main()
  12.  
  13. /*
  14.  * These are the vars we need: the stringList object, a var to hold the
  15.  * list we want to have and the index counter for the list.
  16.  */
  17.  
  18. DEF stringList:PTR TO stringList,
  19.     sortedList,
  20.     index
  21.  
  22.  
  23.  /*
  24.   * Allocate and initialize the object
  25.   */
  26.  
  27.   NEW stringList.new()
  28.  
  29.  
  30.  
  31.  /*
  32.   * Insert some words and get an list. The elist will contain pointers
  33.   * to the alpha-sorted strings.
  34.   */
  35.  
  36.   stringList.fromList(['fire','walk','with','me'])
  37.   sortedList := stringList.asList()
  38.  
  39.  
  40.  
  41.  /*
  42.   * Dump the list.
  43.   */
  44.  
  45.   FOR index := 0 TO ListLen(sortedList)-1
  46.  
  47.     WriteF('\s\n', ListItem(sortedList,index))
  48.  
  49.   ENDFOR
  50.  
  51.  
  52.  
  53.  /*
  54.   * We have to dispose the sorted list we got from asList() since that
  55.   * method allocated it. E's runtime system would free that memory at the
  56.   * end of the program but it is good style...
  57.   */
  58.  
  59.   Dispose(sortedList)
  60.  
  61. ENDPROC
  62.